package com.woniu.cinema.controller;

import java.util.List;

import com.woniu.cinema.vo.MovieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.Movie;
import com.woniu.cinema.service.MovieService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影片信息Controller
 * 
 * @author yy
 * @date 2022-03-30
 */
@RestController
public class MovieController extends BaseController
{
    @Autowired
    private MovieService movieService;


    @RequestMapping("feign/cinema/movie/queryMovieById")
    public List<MovieVo> queryMovieById(@RequestParam("movieId") Integer movieId)
    {
        List<MovieVo> list = movieService.queryMovieById(movieId);
        return list;
    }
    /**
     * 查询影片信息列表
     */
    @GetMapping("/cinema/movie/list")
    public TableDataInfo list(Movie movie)
    {
        startPage();
        List<Movie> list = movieService.selectMovieList(movie);
        return getDataTable(list);
    }

    /**
     * 导出影片信息列表
     */
    @Log(title = "影片信息", businessType = BusinessType.EXPORT)
    @GetMapping("/cinema/movie/export")
    public AjaxResult export(Movie movie)
    {
        List<Movie> list = movieService.selectMovieList(movie);
        ExcelUtil<Movie> util = new ExcelUtil<Movie>(Movie.class);
        return util.exportExcel(list, "movie");
    }

    /**
     * 获取影片信息详细信息
     */
    @GetMapping(value = "/cinema/movie/{movieId}")
    public AjaxResult getInfo(@PathVariable("movieId") Integer movieId)
    {
        return AjaxResult.success(movieService.selectMovieById(movieId));
    }

    /**
     * 新增影片信息
     */
    @Log(title = "影片信息", businessType = BusinessType.INSERT)
    @PostMapping("/cinema/movie")
    public AjaxResult add(@RequestBody Movie movie)
    {
        return toAjax(movieService.insertMovie(movie));
    }

    /**
     * 修改影片信息
     */
    @Log(title = "影片信息", businessType = BusinessType.UPDATE)
    @PutMapping("/cinema/movie")
    public AjaxResult edit(@RequestBody Movie movie)
    {
        return toAjax(movieService.updateMovie(movie));
    }

    /**
     * 删除影片信息
     */
    @Log(title = "影片信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/cinema/movie/{movieIds}")
    public AjaxResult remove(@PathVariable Integer[] movieIds)
    {
        return toAjax(movieService.deleteMovieByIds(movieIds));
    }
}
